<?php  namespace Common\Model;

use Hdphp\Model\Model;

class Type extends Model{
	
	protected $table = 'type';
	
	protected $validate = array(
	
		array('tname','required','商品类型不能为空',3,3),
	
	);
	
	public function addData(){
		//自动验证
		if(!$this->create()) return false;
		//把提交的多个类型名称专为数组
		$typename = explode('|', Q('post.tname'));
		//遍历数组
		foreach ($typename as  $t) {
			//组合数组 调用add方法 添加数组
			$data = array('tname'=>$t);
			$this->add($data);
		}
		return true;
	}
	
	public function editData(){
		if(!$this->create())return false;
		$this->save();
		return true;
	}
	
	
	
}



 ?>